<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>服务处理--CRM客户关系管理系统</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="resources/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="resources/css/public.css" media="all"/>
</head>
<body class="childrenBody">
<form class="layui-form">
    <blockquote class="layui-elem-quote quoteBox">
        <form class="layui-form">
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <input type="text" class="layui-input searchVal" placeholder="请输入客户姓名"/>
                </div>
                <a class="layui-btn search_btn" data-type="reload">搜索</a>
            </div>
        </form>
    </blockquote>
    <table id="serviceDeal" lay-filter="serviceDeal"></table>
    <!--操作-->
    <script type="text/html" id="serviceDealBar">
        <a class="layui-btn layui-btn-xs layui-btn-warm" lay-event="deal">处理</a>
    </script>
</form>
<script type="text/javascript" src="resources/layui/layui.js"></script>
<script type="text/javascript" th:inline="none">
    layui.use(['form', 'layer', 'table', 'laytpl'], function () {
        var form = layui.form,
            layer = parent.layer === undefined ? layui.layer : top.layer,
            $ = layui.jquery,
            laytpl = layui.laytpl,
            table = layui.table;
        //用户列表
        var tableIns = table.render({
            elem: '#serviceDeal',
            url: 'services.do',
            cellMinWidth: 95,
            page: true,
            height: "full-200",
            limits: [10, 15, 20, 25],
            limit: 30,
            id: "serviceDealTable",
            cols: [[
                {type: "checkbox", fixed: "left", width: 50},
                {field: 'id', title: '编号', minWidth: 100, align: "center"},
                {field: 'client', title: '客户', minWidth: 100, align: "center"},
                {field: 'type', title: '服务类型', align: 'center'},
                {field: 'founder', title: '创建人', align: 'center'},
                {
                    field: 'creatTime', title: '创建日期', align: 'center', minWidth: 90, templet: function (obj) {
                        return obj.creatTime;
                    }
                },
                {field: 'outline', title: '概要', align: 'center'},
                {title: '操作', width: 260, templet: '#serviceDealBar', fixed: "right", align: "center"}
            ]]
        });
        //实现搜索功能
        $(".search_btn").click(function () {
            var name = $(".searchVal").val();
            table.reload('serviceDealTable', {url: "services.do?client=" + name});
        });


        // tool(xx)这里的xx是和上边表个的lay-filter="userList"对应的
        table.on("tool(serviceDeal)", function (obj) {
            //获取当前行的数据
            var data = obj.data;
            switch (obj.event) {
                case 'deal':
                    editUser(data);
                    break;
            }
        });
    });
    //进入用户的编辑页面
    function editUser(data){
        var index=layui.layer.open({
            title:"处理服务",
            type:2,
            content:"toServiceDealEdit.do",
            success:function (layero,index) {
                var body = layui.layer.getChildFrame('body', index);//少了这个是不能从父页面向子页面传值的
                body.contents().find("#serviceIdHiden").val(data.id);//这样就将值传递给子页面中id为serviceIdHiden的隐藏域
                body.contents().find(".id").val(data.id);
                body.contents().find(".type").val(data.type);
                body.contents().find(".outline").val(data.outline);
                body.contents().find(".client").val(data.client);
                body.contents().find(".creatTime").val(data.creatTime);
                body.contents().find(".request").val(data.request);
                body.contents().find(".founder").val(data.founder);
                body.contents().find(".assignee").val(data.assignee);
                body.contents().find(".distributeTime").val(data.distributeTime);
                        form.render('select');
                    }
                });
        layui.layer.full(index);//全屏显示
    }
</script>
</body>
</html>